<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/8/2 0002
 * Time: 下午 12:05
 */
namespace app\model;
class SchoolStudentListen extends \think\Model{

    public $table="school_student_listen";


    function add_data($data){
        $data2['content']=$data['content'];
        $data2['pic']=$data['pic'];
        $data2['user_id']=$data['user_id'];
        //$data2['pid']=$data['pid'];

        //$SchoolStudent=new SchoolStudent();
        $data2['school_id']=$data['school_id'];
        $data2['created_at']=cur_time();

        return $this->insertGetId($data2);

    }

    /**
     *
     * @param $school_id
     * @param int $cur_page
     * @return mixed
     */
    function get_page_list($school_id,$cur_page=1){
        $page_size=10;
        $c=($cur_page-1)*$page_size;
        $o=$this->where(['school_id'=>$school_id])->limit($c,$page_size)->select();
        $arrs=object2array($o);
        $User=new User();
        $SchoolStudent=new SchoolStudent();
        $UserResume=new UserResume();
        foreach($arrs as $k=>$v){
            $user_info=[];
            $stu_info=$SchoolStudent->get_student($v['user_id']);
            $user_info['stu_name']=$stu_info['stu_name'];

            $user_re_info=$UserResume->get_head_img_name_by_user_id($v['user_id']);

            $user_info['head_img']=$user_re_info['head_img'];

            $user_info2=$User->get_user_info_by_id($v['user_id']);
            $user_info['exp_job']=$user_info2['exp_job'];
            $arrs[$k]['user_info']=$user_info;
        }
        return $arrs;
    }
}